package com.ctshk.rpc.finance.mapper;

import com.ctshk.rpc.finance.dto.advance.AdvancePaymentManageApplyPageDTO;
import com.ctshk.rpc.finance.dto.supplier.AccountSummaryDTO;
import com.ctshk.rpc.finance.entity.FinanceAdvancePaymentApplySummary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 财务预收款申请汇总表 Mapper 接口
 * </p>
 *
 * @author 谢涛
 * @since 2021-03-23
 */
public interface FinanceAdvancePaymentApplySummaryMapper extends BaseMapper<FinanceAdvancePaymentApplySummary> {

    /**
     * 预收明细
     * @param advancePaymentId
     * @return
     */
    @Select("SELECT id,money_amount,unavailable_amount,available_amount,currency_id,currency,amount_used,remaining_amount \n" +
            "FROM t_finance_advance_payment_apply_summary \n" +
            "WHERE advance_payment_id = #{advance_payment_id} AND is_deleted = 0")
    List<AdvancePaymentManageApplyPageDTO> queryByPayment(@Param("advance_payment_id") Long advancePaymentId);

    /**
     * 查询剩余可用预收款列表
     * @param accountId
     * @return
     */
    @Select("SELECT id,currency,remaining_amount \n" +
            "FROM t_finance_advance_payment_apply_summary \n" +
            "WHERE supplier_id = #{supplier_id} AND is_deleted = 0")
    List<AccountSummaryDTO> queryRemainAmountList(@Param("supplier_id")Long accountId);
}
